import { createRouter, createWebHistory } from 'vue-router'

import LoginVue from '@/views/Login.vue';
import HomeVue from '@/views/Home.vue';

// 框架路由
import LayoutVue from '@/views/Layout.vue';
//室友路由
import RoommateVue from '@/views/Roommate.vue';
// 文本编辑器路由
import MdEditorVue from '@/views/MdEditor.vue';
// 校园分享路由
import ShareVue from '@/views/Share.vue';
// 登录之前路由
import PreLoginVue from '@/views/PreLogin.vue';
// 文章详情路由
import ArticleVue from '@/views/Article.vue'
// 二手集市路由
import MarketVue from '@/views/Market.vue'
// 优惠券路由
import VoucherVue from '@/views/Voucher.vue'

// 室友数据展示路由
import RoommateDataVue from '@/views/RoommateData.vue'

// 404路由
import ErrorVue from '@/views/404.vue';

//定义路由关系
const routes = [
    { path: '/login', component: LoginVue },
    { path: '/', component: PreLoginVue },
    {
        path: '/layout', component: LayoutVue,
        children: [
            { path: '/roommate', component: RoommateVue },
            { path: '/mdEditor', component: MdEditorVue },
            { path: '/share', component: ShareVue },
            { path: '/article/:id', component: ArticleVue },
            { path: '/market', component: MarketVue },
            { path: '/voucher', component: VoucherVue },
            { path: '/RoommateData', component: RoommateDataVue },
        ]
    },
    { path: '/preLogin', component: PreLoginVue },
    { path: '/home', component: HomeVue },
    {
        path: "/:pathMatch(.*)*",
        component: ErrorVue,
        hidden: true
    },


]

//创建路由器
const router = createRouter({
    history: createWebHistory(),
    routes: routes
})

export default router
